var storage = window.localStorage;
var userName;
var lng=$("#lng").val();
var lat=$("#lat").val();

$(function() {
	if(lng==""||lat==""){
		toMap();
	}
	$.ajax({
		url : "./linkAricle/toLinkAricleList.spring",
		type : "POST",
		dataType : 'json',
		success : function(ret) {
			if (ret != null) {
				var html="";
				$("#zixun").html("");
				for (var i = 0; i < ret.length; i++) {
					html += "<li ><a class=\"weui_cell\" href=\""+ret[i].linkAricle+"\" style=\"padding: 0px 5px;\">";
					html += "<div class=\"weui_cell_bd weui_cell_primary\">";
					if(ret[i].title.length>10){
						html += "<p style=\"color: blue;font-size: 13px;margin-left: 8px;\">" + ret[i].title.substring(0,10) + "...</p>";
					}else{
						html += "<p style=\"color: blue;font-size: 13px;margin-left: 8px;\">" + ret[i].title + "</p>";
					}
					html += "</div>";
					html += "<div class=\"weui_cell_ft\"  style=\"font-size: 13px;margin-right: 8px;\">"
							+ ret[i].startTime.substring(0,19) + "</div></a></li>";
				}
				$("#zixun").append(html);
			} else {

			}
		}
	});
});
//诊断自测
function toSelfTest(flag){
	 if(flag!='0'){
		 url="./jsp/conditionsList.jsp";
		 window.location.href=url;
	}else{
		alert("请先登录");
		 url=basePath+"jsp/login.jsp";
		 window.location.href=url;
	}
}
//电子病历
function toCaseHistory(flag){
	if(flag!='0'){
		 url=basePath+"jsp/caseHistory/caseHistoryList.jsp";
		 window.location.href=url;
	}else{
		alert("请先登录");
		 url=basePath+"jsp/login.jsp";
		 window.location.href=url;
	}
	
}
//个人中心
function toCenter(){
	var url=basePath+"home/toCenterList.spring";
	window.location.href=url;
}

//附近医疗
function findHospital(){
	var lng=$("#lng").val();
	var lat=$("#lat").val();
	var url=basePath+"home/findHospital.spring?lng="+lng+"&lat="+lat;
	window.location.href=url;
	 
}

function moreAricle(){
	var url=basePath+"jsp/aricleList.jsp";
	window.location.href=url;
}

function toSmart(){
	var url=basePath+"jsp/smartCabinet.jsp";
	window.location.href=url;
}
function getIness(){
	var url=basePath+"jsp/inessList.jsp";
	window.location.href=url;
}

// 百度地图API功能
function toMap() {
	var map = new BMap.Map("allmap");
	var point = new BMap.Point(116.331398, 39.897445);
	map.centerAndZoom(point, 16);

	var geolocation = new BMap.Geolocation();
	geolocation.getCurrentPosition(function(r) {
		if (this.getStatus() == BMAP_STATUS_SUCCESS) {
			var mk = new BMap.Marker(r.point);
			map.addOverlay(mk);
			map.panTo(r.point);
			lng = r.point.lng;
			lat = r.point.lat;
			$("#lng").val(lng);
			$("#lat").val(lat);
		} else {
			alert('failed' + this.getStatus());
		}
	}, {
		enableHighAccuracy : true
	});
}